package cn.smbms.tools;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;

public class utils {
    private static SqlSessionFactory sqlSessionFactory=null;

     public static SqlSessionFactory open()  {
         try {
             sqlSessionFactory = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("mybatis-config.xml"));
         } catch (IOException e) {
             e.printStackTrace();
         }
         return sqlSessionFactory;
     }


     public static void close(SqlSession session){
         try{
             session.close();
         } catch (Exception e) {
             e.printStackTrace();
         }
     }

}
